package main

// twoSum 两数之和
// 返回 nums 中, 相加之和为 target 的数据下标
func twoSum(nums []int, target int) []int {
	nm := make(map[int]int)
	for i, v := range nums {
		nm[v] = i
	}

	for i, v := range nums {
		if ii, ok := nm[target-v]; ok && ii != i {
			return []int{i, ii}
		}
	}

	return []int{}
}
